<template>
  <div class="con-box uc-order">
    <!-- 导航 -->
    <div class="uc-nav">
      <div class="nav-box">
        <div
          :class="['nav-item', status == '0' ? 'active' : '']"
          @click="changeStatus(0)"
        >
          <span class="text">{{ $t('ucOrder.allOrders') }}</span>
          <i class="line"></i>
        </div>
        <div
          :class="['nav-item', status == '1' ? 'active' : '']"
          @click="changeStatus(1)"
        >
          <span class="text">
            {{ $t('pendingPayment') }}
            <em class="number">{{ orderCountData.unPay }}</em>
          </span>
          <i class="line"></i>
        </div>
        <div
          :class="['nav-item', status == '2' ? 'active' : '']"
          @click="changeStatus(2)"
        >
          <span class="text">
            {{ $t('pendingDelivery') }}
            <em class="number">{{ orderCountData.payed }}</em>
          </span>
          <i class="line"></i>
        </div>
        <div
          :class="['nav-item', status == '3' ? 'active' : '']"
          @click="changeStatus(3)"
        >
          <span class="text">
            {{ $t('pendingReceipt') }}
            <em class="number">{{ orderCountData.consignment }}</em>
          </span>
          <i class="line"></i>
        </div>
        <!-- <div :class="['nav-item',status=='4'?'active':'']" @click="status='4'">
          <span class="text">
            待评价
            <em class="number">{{orderCountData.confirm}}</em>
          </span>
          <i class="line"></i>
        </div>-->
        <div
          :class="['nav-item', status == '5' ? 'active' : '']"
          @click="changeStatus(5)"
        >
          <span class="text">
            {{ $t('completed') }}
            <em class="number">{{ orderCountData.success }}</em>
          </span>
          <i class="line"></i>
        </div>
      </div>
      <!-- <a href=""
      class="recycle-bin">订单回收站</a>-->
    </div>
    <!-- /导航 -->
    <!-- 搜索 -->
    <div class="uc-serach">
      <div class="left">
        <div class="select-item">
          <span class="tit">{{
            [
              $t('ucOrder.allOrders'),
              $t('ucOrder.lastSevenDays'),
              $t('ucOrder.lastThreeMonths'),
              $t('ucOrder.threeMonthsAgo'),
            ][orderTimeStatus]
          }}</span>
          <div class="select">
            <span class="s-item" @click="changeOrderTime(0)">{{
              $t('ucOrder.allOrders')
            }}</span>
            <span class="s-item" @click="changeOrderTime(1)">{{
              $t('ucOrder.lastSevenDays')
            }}</span>
            <span class="s-item" @click="changeOrderTime(2)">{{
              $t('ucOrder.lastThreeMonths')
            }}</span>
            <span class="s-item" @click="changeOrderTime(3)">{{
              $t('ucOrder.threeMonthsAgo')
            }}</span>
          </div>
        </div>
        <div class="select-item">
          <span class="tit">{{
            orderType >= 0
              ? [
                  $t('ucOrder.generalOrders'),
                  $t('ucOrder.groupingOrders'),
                  $t('ucOrder.secondOrders'),
                  $t('ucOrder.pointsOrders'),
                ][orderType]
              : $t('ucOrder.allOrders')
          }}</span>
          <div class="select">
            <span class="s-item" @click="changeOrderType(-1)">{{
              $t('ucOrder.allOrders')
            }}</span>
            <span class="s-item" @click="changeOrderType(0)">{{
              $t('ucOrder.generalOrders')
            }}</span>
            <span class="s-item" @click="changeOrderType(1)">{{
              $t('ucOrder.groupingOrders')
            }}</span>
            <span class="s-item" @click="changeOrderType(2)">{{
              $t('ucOrder.secondOrders')
            }}</span>
            <span class="s-item" @click="changeOrderType(3)">{{
              $t('ucOrder.pointsOrders')
            }}</span>
          </div>
        </div>
      </div>
      <div class="right">
        <div class="search-value">
          <div class="ordernum" @click="showOptions()">
            {{
              type == 0 ? $t('ucOrder.orderNumber') : $t('ucOrder.productName')
            }}
          </div>
          <div class="options" v-if="showOptionsBox">
            <p
              class="options-item"
              @click="selectSearchValue(0)"
              v-if="type == 1"
            >
              {{ $t('ucOrder.orderNumber') }}
            </p>
            <p
              class="options-item"
              @click="selectSearchValue(1)"
              v-if="type == 0"
            >
              {{ $t('ucOrder.productName') }}
            </p>
          </div>
        </div>
        <div class="search-int">
          <input
            type="text"
            class="input"
            v-model="orderNumber"
            @keyup.enter="searchOrder"
            v-if="type == 0"
            :placeholder="$t('ucOrder.enterNumberpSearch')"
          />
          <input
            type="text"
            class="input"
            v-model="orderName"
            @keyup.enter="searchOrder"
            v-if="type == 1"
            :placeholder="$t('ucOrder.enterProductSearch')"
          />
        </div>
        <a href="javascript:void(0)" class="search" @click="searchOrder(1)">{{
          $t('ucOrder.checkOrder')
        }}</a>
      </div>
    </div>
    <!-- /搜索 -->
    <!-- 订单列表 -->
    <div class="order-list" v-if="orderList.length">
      <div class="order-table">
        <table cellspacing="0" cellpadding="0" class="box">
          <tbody>
            <tr class="box-tit">
              <th>{{ $t('products') }}</th>
              <!--  class="pl" -->
              <th width="110">{{ $t('quantity') }}</th>
              <th width="120" class="pr">{{ $t('priceOne') }}</th>
              <th width="130">{{ $t('totalAll') }}</th>
              <th width="130">{{ $t('status') }}</th>
              <th width="130">{{ $t('operation') }}</th>
            </tr>
          </tbody>
          <tbody v-for="(order, index) in orderList" :key="index">
            <tr class="box-space">
              <td colspan="6"></td>
            </tr>
            <tr class="box-hd">
              <td colspan="6">
                <div class="time">{{ order.createTime }}     </div>
                <div class="order-number">
                  {{ $t('orderNumberT') }}：
                  <span class="num">{{ order.orderNumber }}   </span>
                </div>
                <div style="margin-left: 10px;" class="order-number" v-if="order.collaborativePurchaseId">
                  协同采购单：
                  <span class="num">{{ order.collaborativePurchaseId }}   </span>
                </div>
                <!-- 图标有了但没有文字显示 -->
                <div
                  @click="toShop(order.shopId)"
                  class="shop"
                  style="margin-left: 140px"
                >
                  <span class="shop-icon"></span>
                  {{ order.shopName }}
                  <span v-if="order.shopName == null">{{$t('ucOrder.officialSelf')}}</span>
                  <!-- 跳转客服 -->
                  <span @click.stop="toChat(order.shopId,order.shopName)" class="btn-im" target="view_window"></span>
                </div>
                <div
                  class="del"
                  v-if="order.status >= 5 && order.status != 7"
                  @click="showDelPop(order.orderNumber)"
                ></div>
              </td>
            </tr>
            <tr
              class="box-tr"
              v-for="(orderItem, index) in order.orderItemDtos"
              :key="index"
            >
              <td>
                <div class="goods-info">
                  <a
                    :href="
                      (order.orderType == 3
                        ? '/member-center/integral-det/'
                        : '/detail/') + orderItem.prodId
                    "
                    class="img"
                  >
                    <img :src="orderItem.pic" alt />
                  </a>
                  <div class="name-sku">
                    <a
                      :href="
                        (order.orderType == 3
                          ? '/member-center/integral-det/'
                          : '/detail/') + orderItem.prodId
                      "
                      class="name"
                      >{{ orderItem.prodName }}</a
                    >
                    <span class="sku">{{ orderItem.skuName }}</span>
                  </div>
                </div>
                <!-- <a href="javascript:void(0);"
                   class="goods-return"
                   :data-ordernumber="order.orderNumber"
                @click="toApplyReturn($event)">申请售后</a>-->
              </td>
              <td>
                <!--  class="pl" -->
                <div class="goods-number">×{{ orderItem.prodCount }}</div>
              </td>
              <td class="pr">
                <div class="amount">
                  <div class="price">
                    <span v-if="orderItem.price"
                      >￥{{ parsePrice(orderItem.price)[0] }}.{{
                        parsePrice(orderItem.price)[1]
                      }}</span
                    >
                    <!-- <span v-if="orderItem.price && orderItem.useScore">+</span>
                    <span v-if="orderItem.useScore"
                      >{{ orderItem.useScore }} 积分</span
                    > -->
                  </div>
                </div>
              </td>
              <td
                :rowspan="order.orderItemDtos.length"
                v-if="index == 0"
                class="bl"
              >
                <div class="amount">
                  <div class="price">
                    <span v-if="order.actualTotal"
                      >￥{{ parsePrice(order.actualTotal)[0] }}.{{
                        parsePrice(order.actualTotal)[1]
                      }}</span
                    >
                    <span v-if="order.actualTotal && order.userScore">+</span>
                    <span v-if="order.userScore"
                      >{{ order.userScore }} {{ $t('ucOrder.points') }}</span
                    >
                    <!-- <span v-if="order.useScoreTotal"
                      >{{ order.useScoreTotal }} 积分</span
                    > -->
                  </div>
                  {{ $t('ucOrder.onlinePayment') }}
                </div>
              </td>
              <td
                :rowspan="order.orderItemDtos.length"
                v-if="index == 0"
                class="bl"
              >
                <div class="status">
                  <div
                    :class="[
                      'text',
                      order.status > 4 && order.status != 7 ? '' : 'no-finish',
                    ]"
                  >
                    {{
                      [
                        '',
                        $t('pendingPayment'),
                        $t('pendingDelivery'),
                        $t('pendingReceipt'),
                        $t('pendinEvaluation'),
                        $t('completed'),
                        $t('canceled'),
                        $t('grouping'),
                      ][order.status]
                    }}
                  </div>
                  <a
                    href="javascript:void(0);"
                    @click="toOrderDetail(order.orderNumber)"
                    class="order-detail"
                    style="background: #ffffff"
                    >{{ $t('ucOrder.orderDetails') }}</a
                  >
                </div>
              </td>
              <td
                :rowspan="order.orderItemDtos.length"
                v-if="index == 0"
                class="bl"
              >
                <div class="action">
                  <a
                    href="javascript:void(0);"
                    v-if="
                      order.status != 2 &&
                      order.status != 4 &&
                      order.status != 7
                    "
                    @click="orderOperation($event)"
                    :data-status="order.status"
                    :data-ordernumber="order.orderNumber"
                    :data-total="order.actualTotal"
                    :data-ordertype="order.orderType"
                    :class="[
                      'action-btn',
                      order.status > 4 ? 'default' : 'active',
                    ]"
                    >{{
                      [
                        '',
                        $t('ucOrder.payNow'),
                        $t('ucOrder.remindSellers'),
                        $t('ucOrder.confirmReceipt'),
                        '',
                        $t('ucOrder.buyAgain'),
                        $t('ucOrder.buyAgain'),
                      ][order.status]
                    }}</a
                  >
                  <!-- 官方自营无法收藏 -->
                  <!-- v-if=" order.status > 2 && order.status != 3 && order.shopId !== null " -->
                  <!-- 3.查看物流 4.再次购买 5 6添加收藏 -->
                  <!-- <a
                    href="javascript:void(0);"
                    @click="operator(order.status, order.orderNumber)"
                    class="action-a"
                    v-if="
                      order.status > 2 &&
                        order.status != 3 &&
                        order.shopId !== null
                    "
                    >{{
                      [
                        '',
                        '',
                        '',
                        '查看物流',
                        '再次购买',
                        '添加收藏',
                        '添加收藏'
                      ][order.status]
                    }}</a
                  > -->
                  <a
                    href="javascript:void(0);"
                    @click="operator(order.status, order.orderNumber)"
                    class="action-a"
                    v-if="order.shopId !== null"
                    >{{ $t('ucOrder.addFavorites') }}</a
                  >
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <!-- 提示弹窗 -->
      <div class="popup-mask" v-if="showTips"></div>
      <div class="popup-box" v-if="showTips">
        <div class="tit">
          <div class="text">{{ $t('ucOrder.tips') }}</div>
          <div class="close" @click="showTips = 0"></div>
        </div>
        <div class="con">
          <div class="tip">
            <div class="tip-icon warning"></div>
            <div class="tip-info">
              <div class="result" v-if="showTips == 3">
                {{ $t('ucOrder.sureReceivedGoods') }}
              </div>
              <div class="date" v-if="showTips == 3">
                {{ $t('ucOrder.considerCarefully') }}
              </div>
              <div class="result" v-if="showTips == 6">
                {{ $t('ucOrder.deleteTheOrder') }}
              </div>
              <div class="date" v-if="showTips == 6">
                {{ $t('ucOrder.ordersNotRecovered') }}
              </div>
              <div class="btns">
                <a
                  href="javascript:void(0);"
                  class="btn-r"
                  @click="confirmReceive"
                  v-if="showTips == 3"
                  >{{ $t('ucOrder.confirmReceipt') }}</a
                >
                <a
                  href="javascript:void(0);"
                  class="btn-r"
                  @click="delOrder"
                  v-if="showTips == 6"
                  >{{ $t('delete') }}</a
                >
                <a
                  href="javascript:void(0);"
                  class="btn-g"
                  @click="cancelOpera"
                  >{{ $t('cancel') }}</a
                >
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 页码 -->
      <pagination
        v-model="current"
        :pages="pages"
        :current="current"
        :size="size"
        @changePage="getSearchProdPage(current)"
      ></pagination>
      <!-- /页码 -->
    </div>
    <!-- /订单列表 -->
    <!-- 空列表提示 -->
    <div class="empty" v-if="!orderList.length">
      <div class="img">
        <img src="~/assets/images/emptyPic/order-empty.png" alt />
      </div>
      <div class="action">
        <div class="text">{{ $t('ucOrder.nanOrderYet') }}</div>
        <nuxt-link to="/" class="btn">{{ $t('ucOrder.goShopping') }}</nuxt-link>
      </div>
    </div>
    <!-- /空列表提示 -->
  </div>
</template>

<script>
import Pagination from '~/components/pagination'
import Cookie from 'js-cookie'

export default {
  data() {
    return {
      current: 1, // 当前页
      pages: 1, // 总页数
      size: 5,
      orderCountData: {},
      orderList: [],
      status: 0,
      orderNumber: null,
      orderName: null,
      orderTimeStatus: 0, // 订单时间筛选
      orderType: -1, // 订单类型筛选
      showTips: 0,
      delOrderNumber: '', // 要删除的订单号
      type: 0, //查询类型  0订单编号 1商品名称
      showOptionsBox: false, //是否显示查询选项,
      addCount: 0,
    }
  },
  components: {
    Pagination,
  },
  created() {
    this.status = this.$route.query.status || 0
  },
  mounted() {
    // 设置网页标题
    document.title = this.$i18n.t('userCenter.myOrders')
    if (localStorage.getItem('current') !== null) {
      this.orderList = JSON.parse(localStorage.getItem('orderList'))
      this.current = JSON.parse(localStorage.getItem('current'))
    }
    this.getUserInfo() //获取订单数量
    this.getOrderList() //获取订单列表
  },

  methods: {
    /**
     * 跳转客服
     */
    toChat(shopId,shopName) {
      let routeUrl = this.$router.resolve({
        path: '/chat?shopId=' + shopId + (shopName==null?'&chatType=1':'')
      });
      window.open(routeUrl.href, 'view_window');
    },
    /**
     * 跳转店铺页
     */
    toShop(shopId) {
     this.$router.push({path: `/shopIndex?sid=${shopId}`})
    },

    /**
     * 切换订单状态
     * staus 0 = 全部 1 = 待支付 2 = 待发货 3 = 待收货  5 = 已完成
     */
    changeStatus(status) {
      this.status = status
      this.current = 1
      this.getOrderList()
      this.getUserInfo()
    },

    /**
     * 获取订单数量
     */
    getUserInfo() {
      this.$axios.get('/p/user/centerInfo').then(({ data }) => {
        this.orderCountData = data.orderCountData
      })
    },
    /**
     * 获取订单列表
     */
    getOrderList() {
      let params = {
        current: this.current,
        size: this.size,
        status: this.status,
        orderName: '',
        orderTimeStatus: this.orderTimeStatus || '',
        orderType: this.orderType >= 0 ? this.orderType : '',
        orderNumber: '',

      }
      this.$axios
        .get('/p/myOrder/myOrderSearch', { params })
        .then(({ data }) => {
          data.records.forEach((order) => {
            order.useScoreTotal = 0
            order.orderItemDtos.forEach((orderItem) => {
              if (orderItem.useScore) {
                order.useScoreTotal += orderItem.useScore
              }
            })
          })
          this.orderList = data.records
          this.pages = data.pages
          scrollTo(0, 0)
        })
    },
    /**
     * 分页
     */
    getSearchProdPage(current) {
      this.searchOrder()
      // if (this.orderName) {
      //   this.searchOrder()
      // } else {
      //   this.getOrderList()
      // }
    },

    /**
     * 显示选项框
     */
    showOptions() {
      this.showOptionsBox = !this.showOptionsBox
    },
    /**
     * 获取查询类型
     */
    selectSearchValue(type) {
      this.type = type
      this.showOptionsBox = false
      ;(this.orderName = ''), (this.orderNumber = '')
    },

    /**
     * 根据订单编号/商品名称 搜索订单
     */
    searchOrder(query) {
      this.$axios
        .get('/p/myOrder/myOrderSearch', {
          params: {
            status: this.status,
            orderNumber: this.orderNumber || '',
            orderName: this.orderName || '',
            orderTimeStatus: this.orderTimeStatus,
            orderType: this.orderType >= 0 ? this.orderType : '',
            current: query ? 1 : this.current,
            size: this.size,
          },
        })
        .then(({ data }) => {
          this.orderList = data.records
          this.pages = data.pages
          if (this.current !== undefined) {
            localStorage.setItem('orderList', JSON.stringify(this.orderList))
            localStorage.setItem('current', JSON.stringify(this.current))
          }
        })
      this.current = this.current
      if(query) {
        this.orderNumber = ''
      }
    },
    /**
     * 跳转订单详情
     */
    toOrderDetail(orderNumber) {
      this.$router.push({
        path: '/order-detail',
        query: { orderNumber: orderNumber },
      })
    },
    /**
     * 订单操作
     */
    orderOperation(e) {
      // status: 1立即付款 3确认收货  5再次购买 6立即购买
      const { status, ordernumber, total, ordertype } = e.target.dataset
      console.log(status)
      switch (status) {
        case '1':
          sessionStorage.setItem('pay_total', total)
          sessionStorage.setItem('pay_orderNumber', ordernumber)
          this.$router.push({ path: '/payment' })
          break
        case '3':
          this.showTips = 3 // 确认收货提醒
          this.currentOrderNumber = ordernumber
          break
        case '5':
          let that = this
          var prodList = []
          that.orderList.forEach((el) => {
            if (el.orderNumber == ordernumber) {
              prodList = el.orderItemDtos
              this.addCart(prodList,el.shopId,el.shopName)
            }
          })
          // this.$router.push({ path: (ordertype == 3 ? '/member-center/integral-det/' : '/detail/') + prodId })
          break
        case '6':
          var prodId = 0
          this.orderList.forEach((el) => {
            if (el.orderNumber == ordernumber) {
              prodId = el.orderItemDtos[0].prodId
            }
          })
          this.$router.push({
            path:
              (ordertype == 3 ? '/member-center/integral-det/' : '/detail/') +
              prodId,
          })
          break
        default:
          break
      }
    },
    /**
     * 批量加入购物车
     */
    async addCart(prodList, shopId, shopName) {
      try {
        for (let i = 0; i < prodList.length; i++) {
            await this.addToCart(prodList[i], shopId, shopName)
            console.log(i)
          }
            this.$message.success(
            this.$t('success') + this.$t('prodDetail.addToCart')
         )
      } catch (error) {
        console.log(error)
      }
      this.$router.push({ path: '/cart' })
    },
    /**
     * 加入购物车
     */
    addToCart(prod, shopId, shopName) {
      // }
      console.log(prod)
      return this.$axios
        .post('/p/shopCart/changeItem', {
          basketId: 0,
          count: prod.prodCount,
          prodId: prod.prodId,
          shopId: shopId,
          shopName: shopName,
          skuId: prod.skuId,
          // distributionCardNo: this.distributionCardNo
        }).then(res=>{
          this.getCartCount()
        })
    },
    /**
     * 获取购物车商品总数
     */
    getCartCount() {
      this.$axios.get('/p/shopCart/prodCount').then(({ data }) => {
        this.$store.commit('cartNumber/changeCartNumber', data)
      })
    },
    /**
     * 申请售后
     */
    toApplyReturn(e) {
      const orderNumber = e.target.dataset.ordernumber //订单号
      this.orderList.forEach((el, index) => {
        if (el.orderNumber == orderNumber) {
          //保存数据
          localStorage.setItem('orderItem', JSON.stringify(el))
          localStorage.setItem(
            'orderItemDtos',
            JSON.stringify(el.orderItemDtos)
          )
        }
      })
      this.$router.push({
        path: 'apply-return',
        query: { orderNumber: orderNumber },
      })
    },

    /**
     * 订单确认收货
     */
    confirmReceive() {
      this.showTips = 0
      this.$axios
        .put('/p/myOrder/receipt/' + this.currentOrderNumber)
        .then(({ data }) => {
          this.$message({
            message: this.$i18n.t('ucOrder.confirmReceiptSuccessfully'),
            type: 'success',
            duration: 1000,
          })
          this.getOrderList()
          this.getUserInfo()
        })
    },

    /**
     * 操作
     */
    // operator (status, orderNumber) {
    //   // 3'查看物流' 4'再次购买' 5 6'添加收藏'
    //   // if (status == 3) {
    //   //   this.$router.push({ path: '/order-detail', query: { orderNumber: orderNumber } })
    //   // } else
    //   if (status == 4) {
    //     var prodId = 0
    //     this.orderList.forEach(el => {
    //       if (el.orderNumber == orderNumber) {
    //         prodId = el.orderItemDtos[0].prodId
    //       }
    //     })
    //     this.$router.push({ path: (ordertype == 3 ? '/member-center/integral-det/' : '/detail/') + prodId })
    //   } else if (status == 5 || status == 6) {
    //     var prodIds = []
    //     this.orderList.forEach(el => {
    //       if (el.orderNumber == orderNumber) {
    //         el.orderItemDtos.forEach(prodItem => {
    //           prodIds.push(prodItem.prodId)
    //         })
    //       }
    //     })
    //     this.addFavProd(prodIds)
    //   }
    // },
    operator(status, orderNumber) {
      // 添加收藏
      var prodIds = []
      this.orderList.forEach((el) => {
        if (el.orderNumber == orderNumber) {
          el.orderItemDtos.forEach((prodItem) => {
            prodIds.push(prodItem.prodId)
          })
        }
      })
      console.log(prodIds)
      this.addFavProd(prodIds)
    },

    /**
     * 取消操作
     */
    cancelOpera() {
      this.getOrderList()
      this.showTips = 0
    },

    /**
     * 添加收藏
     */
    addFavProd(prodIds) {
      // 相同id去重
      var prodIdStr = Array.from(new Set(prodIds)).toString()
      // 查询商品是否已收藏
      if (!Cookie.get('token')) {
        return
      }
      this.$axios
        .get('/p/user/collection/isCollection', {
          params: {
            prodId: prodIdStr,
          },
        })
        .then(({ data }) => {
          if (data) {
            this.$message({
              message: this.$i18n.t('ucOrder.collected'),
              type: 'success',
              duration: 1000,
            })
          } else {
            this.$axios
              .post('/p/user/collection/orderProdCollectionAll', prodIdStr)
              .then(({ data }) => {
                this.$message({
                  message: this.$i18n.t('ucOrder.productCollectionSuccess'),
                  type: 'success',
                  duration: 1000,
                })
              })
          }
        })
    },

    /**
     * 删除确认弹窗
     */
    showDelPop(orderNumber) {
      this.showTips = 6
      this.delOrderNumber = orderNumber
    },

    /**
     * 删除确认弹窗
     */
    showDelPop(orderNumber) {
      this.showTips = 6
      this.delOrderNumber = orderNumber
    },

    /**
     * 删除订单
     */
    delOrder() {
      this.$axios
        .delete('/p/myOrder/' + this.delOrderNumber)
        .then(({ data }) => {
          this.showTips = 0
          this.$message({
            type: 'success',
            duration: 1000,
            message: data,
          })
          this.getOrderList()
          this.getUserInfo()
        })
    },

    /**
     * 切换订单时间
     */
    changeOrderTime(orderTimeStatus) {
      this.orderName = ''
      this.orderNumber = ''
      this.orderTimeStatus = orderTimeStatus
      this.searchOrder()
      this.$forceUpdate()
    },

    /**
     * 切换订单类型
     */
    changeOrderType(orderType) {
      this.orderName = ''
      this.orderNumber = ''
      this.orderType = orderType
      this.searchOrder()
    },

    /**
     * 价格处理
     */
    parsePrice(value) {
      var val = Number(value)
      if (!val) {
        val = 0
      }
      // 截取小数点后两位，并以小数点为切割点将val转化为数组
      return val.toFixed(2).split('.')
    },
  },

  watch: {
    status() {
      this.current = this.current
      this.orderName = ''
      this.orderNumber = ''
    },
    orderType() {
      this.orderName = ''
      this.orderNumber = ''
    },
  },
}
</script>

<style scoped src='~/assets/css/uc-order.css'></style>
<style scoped src='~/assets/css/user-center.css'></style>
<style scoped>
.empty {
  width: 1080px;
  margin: 80px auto;
  text-align: center;
  font-size: 14px;
}
</style>
